home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
BASIC
/
0745.ZIP
/
CASESHFT.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-09-21
|
2KB
|
60 lines
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'
' CASESHFT - A subroutine to convert the case of alphabet characters within
' a supplied string according to the supplied select type.
'
' Author.: Frank R. Aguilar
' P O Box 2353
' Laredo, TX 78044-2353 CIS ID# 72447,3304
'
' Date...: September 21, 1986
'
' EXAMPLE: CALL CASESHIFT (X$,SELECT%)
'
' Where..: X$ - String of which is to be converted.
' SELECT% - Select type of one of the following:
' 1 - Convert all alphabet characters to upper case.
' 2 - Convert all alphabet characters to lower case.
' 3 - Convert first byte of alphabet word to upper case
' and the rest of the bytes of that word to lower.
'
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SUB CASESHFT (X$,SELECT%) STATIC
IF SELECT%=1 THEN
FOR I%=1 TO LEN(X$)
X%=ASC(MID$(X$,I%,1))
LCASE%=(X%>96 AND X%<123)
IF LCASE% THEN MID$(X$,I%,1)=CHR$(X% XOR 32)
NEXT I%
ELSEIF SELECT%=2 THEN
FOR I%=1 TO LEN(X$)
X%=ASC(MID$(X$,I%,1))
LCASE%=(X%>64 AND X%<91)
IF LCASE% THEN MID$(X$,I%,1)=CHR$(X% XOR 32)
NEXT I%
ELSEIF SELECT%=3 THEN
LB%=0
FOR I%=1 TO LEN(X$)
X%=ASC(MID$(X$,I%,1))
UCASE%=(X%>64 AND X%<91)
LCASE%=(X%>96 AND X%<123)
ALPHA%=UCASE% OR LCASE%
IF ALPHA% THEN
IF(LB% AND UCASE%)OR(LB%=0 AND LCASE%) THEN_
MID$(X$,I%,1)=CHR$(X% XOR 32)
LB%=1
ELSE
LB%=0
END IF
NEXT I%
END IF
END SUB